/**
 * 
 */
package pt.mleiria.bean;

import java.io.Serializable;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import pt.mleiria.bo.LoginEJB;
import pt.mleiria.utils.Messages;
import pt.mleiria.utils.Navigator;

/**
 * @author NB13712
 * 
 */
@ManagedBean(name = "loginBean")
@SessionScoped
public class EntryPointBean extends MasterBean implements Serializable {
	

	@EJB
	private LoginEJB loginEjb;

	public LoginEJB getLoginEjb() {
		return loginEjb;
	}

	private static final long serialVersionUID = 1L;
	private String username = "Manuel";
	private String password = "Leiria";

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String login() {
		boolean isIt = loginEjb.isUserAuthenticated(username, password);
		if (isIt) {
			index = Navigator.Overview.getValue();
			return Navigator.Overview.getLnk();
		} else {
			return "index";
		}
	}

	public String clear() {
		username = "";
		password = "";
		return "index";
	}

}
